package com.tanhua.app.controller;

import com.tanhua.app.service.MakeFriendService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@RestController
public class MakeFriendController {
    @Autowired
    private MakeFriendService makeFriendService;

    @GetMapping(value = "/tanhua/todayBest", name = "今日佳人")
    public ResponseEntity findTodayBest() {
        return makeFriendService.findTodayBest();
    }


    @GetMapping(value = "/tanhua/recommendation", name = "推荐用户")
    public ResponseEntity recommendation(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                                         @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize){
        return makeFriendService.recommendation(pageNum,pageSize);

    }
    @GetMapping(value = "/movements/visitors",name = "最近访问")
    public ResponseEntity visitors(){
        return makeFriendService.visitors();
    }
    @GetMapping(value = "/tanhua/{bestUserId}/personalInfo", name = "佳人详情")
    public ResponseEntity personalInfo(@PathVariable Long bestUserId){
        return makeFriendService.personalInfo(bestUserId);
    }
    @GetMapping(value ="/tanhua/strangerQuestions",name = "查看陌生人问题")
    public ResponseEntity findQuestionsByUserId(Long userId){
        String text =makeFriendService.findQuestionsByUserId(userId);
        return ResponseEntity.ok(text);
    }
    @PostMapping(value = "/tanhua/strangerQuestions",name = "回答陌生人问题")
    public ResponseEntity replyQuestions(@RequestBody Map<String,String> param){
        String userId = param.get("userId");
        String reply = param.get("reply");

        return makeFriendService.replyQuestions(userId,reply);
    }
    }

